Skip to content

Conversation

@andrewqian2001datadog
Copy link
Contributor

@andrewqian2001datadog andrewqian2001datadog commented Jan 20, 2026

Summary

This PR adds sampling (probalistic, error) for OTLP traces that match the agent's behavior.

In the agent, the priority sampler, and the error sampler is enabled by default

  1. code showing that TargetTps and ErrorTps are set to non zero values

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

How did you test this PR?

Correctness tests, manual testing.

build adp and run with sampling enabled.

DD_DATA_PLANE_OTLP_ENABLED=true \
        DD_DATA_PLANE_OTLP_PROXY_ENABLED=false \
        DD_OTLP_CONFIG='{}' \
        DD_APM_CONFIG__PROBABILISTIC_SAMPLER__ENABLED=true \
        DD_APM_CONFIG__PROBABILISTIC_SAMPLER__SAMPLING_PERCENTAGE=50 \
        RUST_LOG=info \
        make run-adp-standalone

Send traces, verify that around ~DD_APM_CONFIG__PROBABILISTIC_SAMPLER__SAMPLING_PERCENTAGE are missing from the trace explorer.

TIME_NS=$(python3 - <<'PY'
import time
print(time.time_ns())
PY
)
END_NS=$((TIME_NS + 1_000_000))
TRACE_ID_B64=$(python3 - <<'PY'
import os,base64
print(base64.b64encode(os.urandom(16)).decode())
PY
)
SPAN_ID_B64=$(python3 - <<'PY'
import os,base64
print(base64.b64encode(os.urandom(8)).decode())
PY
)
grpcurl -plaintext \
  -import-path /Users/andrew.qian/Documents/Code/agent-related/saluki/lib/protos/otlp/proto \
  -proto opentelemetry/proto/collector/trace/v1/trace_service.proto \
  -d @ 127.0.0.1:4317 \
  opentelemetry.proto.collector.trace.v1.TraceService/Export <<JSON
{
  "resourceSpans": [{
    "resource": {
      "attributes": [
        { "key": "service.name", "value": { "stringValue": "saluki-adp" } },
        { "key": "deployment.environment", "value": { "stringValue": "wacktest" } },
        { "key": "host.name", "value": { "stringValue": "COMP-JGW6V7JHF1" } }
      ]
    },
    "scopeSpans": [{
      "scope": { "name": "test-client", "version": "0.1.0" },
      "spans": [{
        "traceId": "$TRACE_ID_B64",
        "spanId": "$SPAN_ID_B64",
        "name": "test-span",
        "kind": 1,
        "startTimeUnixNano": "$TIME_NS",
        "endTimeUnixNano": "$END_NS",
        "attributes": [
          { "key": "env", "value": { "stringValue": "wacktest4" } },
          { "key": "operation.name", "value": { "stringValue": "adp.test" } },
          { "key": "resource.name", "value": { "stringValue": "GET /api" } },
          { "key": "span.type", "value": { "stringValue": "web" } },
          { "key": "sampling.priority", "value": { "intValue": 2 } },
          { "key": "test.run", "value": { "stringValue": "adp-otlp-2" } },
          { "key": "http.method", "value": { "stringValue": "GET" } },
          { "key": "http.url", "value": { "stringValue": "https://example.com/api" } },
          { "key": "http.status_code", "value": { "intValue": 200 } }
        ],
        "status": { "code": 1 }
      }]
    }]
  }]
}
JSON

View the trace explorer (link). I use the env "wacktest4" to filter for my spans, and for some reason the live explorer is not working for me but idk.

References

@andrewqian2001datadog andrewqian2001datadog changed the title Andrewq/add trace sampling (WIP) Andrewq/add trace sampling Jan 20, 2026
@github-actions github-actions bot added area/core Core functionality, event model, etc. area/components Sources, transforms, and destinations. labels Jan 20, 2026
@pr-commenter
Copy link

pr-commenter bot commented Jan 20, 2026

Binary Size Analysis (Agent Data Plane)

Target: be34af7 (baseline) vs b0ba6d8 (comparison) diff
Analysis Type: Stripped binaries (debug symbols excluded)
Baseline Size: 27.54 MiB
Comparison Size: 27.63 MiB
Size Change: +89.62 KiB (+0.32%)
Pass/Fail Threshold: +5%
Result: PASSED ✅

Changes by Module

Module File Size Symbols
saluki_components::transforms::trace_sampler +35.11 KiB 23
core +31.12 KiB 66
hashbrown +9.00 KiB 7
saluki_core::data_model::event +5.95 KiB 7
ZN76<saluki_core -5.72 KiB 2
[sections] +3.64 KiB 7
serde_core +2.12 KiB 8
saluki_components::common::datadog +1.87 KiB 17
saluki_components::common::otlp +1.44 KiB 2
saluki_core::topology::blueprint +1.27 KiB 1
saluki_config::GenericConfiguration::try_get_typed +1.23 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.10093 +1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.10090 -1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.8479 +1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.8784 +1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.9054 +1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.8476 -1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.8781 -1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.9051 -1.10 KiB 1
_ZN4http6header4name14StandardHeader6as_str17hb45bedc01a2a74c0E.10812 +1.10 KiB 1

Detailed Symbol Changes

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +3.6% +69.7Ki  +4.1% +60.9Ki    [630 Others]
  [NEW] +27.3Ki  [NEW] +27.2Ki    saluki_components::transforms::apm_stats::ApmStats::process_trace::hea01e15f0321d337
  [NEW] +20.4Ki  [NEW] +20.3Ki    saluki_components::encoders::datadog::traces::TraceEndpointEncoder::encode_tracer_payload::h8e94d45f42e4f777
  [NEW] +14.8Ki  [NEW] +14.6Ki    _<saluki_components::transforms::trace_sampler::TraceSampler as saluki_core::components::transforms::Transform>::run::_{{closure}}::h85b5a4b8d8f03e25
  [NEW] +13.9Ki  [NEW] +13.7Ki    _<core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize::h9e9260c51df6c275
  [NEW] +11.5Ki  [NEW] +11.3Ki    saluki_components::common::datadog::apm::ApmConfig::from_configuration::had70a6878fa7d173
  [NEW] +7.61Ki  [NEW] +7.48Ki    saluki_components::transforms::trace_sampler::score_sampler::ScoreSampler::sample::hfc28eb294ce41497
  [NEW] +6.13Ki  [NEW] +6.00Ki    _ZN76_<hickory_proto::rr::record_data::RData as core::clone::Clone>5clone17h61f3fe4fffa4b03dE.8776
  [NEW] +5.65Ki  [NEW] +5.50Ki    _<core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize::hf0643ecc9b96a441
  [NEW] +5.52Ki  [NEW] +5.39Ki    _ZN76_<hickory_proto::rr::record_data::RData as core::clone::Clone>5clone17h61f3fe4fffa4b03dE.11905
  [NEW] +5.35Ki  [NEW] +5.23Ki    _ZN59_<rustls::error::Error as core::clone::Clone>5clone17hd14a1219ce5dde1cE.10816
  [NEW] +5.27Ki  [NEW] +5.14Ki    _<saluki_core::data_model::event::trace::Span as core::clone::Clone>::clone::h67b60e9c023e938d
  [DEL] -5.21Ki  [DEL] -5.09Ki    _ZN59_<rustls::error::Error as core::clone::Clone>5clone17hd14a1219ce5dde1cE.11853
  [DEL] -5.35Ki  [DEL] -5.23Ki    _ZN59_<rustls::error::Error as core::clone::Clone>5clone17hd14a1219ce5dde1cE.10807
  [DEL] -5.52Ki  [DEL] -5.39Ki    _ZN76_<hickory_proto::rr::record_data::RData as core::clone::Clone>5clone17h61f3fe4fffa4b03dE.11890
  [DEL] -6.13Ki  [DEL] -6.00Ki    _ZN76_<hickory_proto::rr::record_data::RData as core::clone::Clone>5clone17h61f3fe4fffa4b03dE.8773
  [DEL] -10.5Ki  [DEL] -10.3Ki    _ZN76_<saluki_core::data_model::event::Event as core::clone::Clone>5clone17h7f500b934c4a671bE.10782
  [DEL] -11.1Ki  [DEL] -11.0Ki    saluki_components::common::datadog::apm::ApmConfig::from_configuration::hde97307d5b1f378a
  [DEL] -12.3Ki  [DEL] -12.1Ki    _<core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize::hf57b1009e3f2b7f6
  [DEL] -20.1Ki  [DEL] -20.0Ki    saluki_components::encoders::datadog::traces::TraceEndpointEncoder::encode_tracer_payload::h253c709930a63a8e
  [DEL] -27.3Ki  [DEL] -27.2Ki    saluki_components::transforms::apm_stats::ApmStats::process_trace::hf762265449fd0933
  +0.3% +89.6Ki  +0.3% +80.4Ki    TOTAL

@pr-commenter
Copy link

pr-commenter bot commented Jan 20, 2026

Regression Detector (Agent Data Plane)

Regression Detector Results

Run ID: 920e3daf-a7ba-4092-b53b-43d9a4826bd2

Baseline: be34af7
Comparison: b0ba6d8
Diff

❌ Experiments with retried target crashes

This is a critical error. One or more replicates failed with a non-zero exit code. These replicates may have been retried. See Replicate Execution Details for more information.

  • quality_gates_rss_dsd_low
  • quality_gates_rss_dsd_ultraheavy
  • otlp_ingest_traces_5mb_throughput

Optimization Goals: ❌ Regression(s) detected

perf experiment goal Δ mean % Δ mean % CI trials links
otlp_ingest_traces_5mb_cpu % cpu utilization +8.24 [+5.71, +10.78] 1 (metrics) (profiles) (logs)

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
otlp_ingest_logs_5mb_memory memory utilization +9.24 [+8.75, +9.73] 1 (metrics) (profiles) (logs)
otlp_ingest_logs_5mb_throughput ingress throughput +0.01 [-0.12, +0.14] 1 (metrics) (profiles) (logs)
otlp_ingest_logs_5mb_cpu % cpu utilization -0.42 [-5.49, +4.65] 1 (metrics) (profiles) (logs)

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
dsd_uds_512kb_3k_contexts_cpu % cpu utilization +11.82 [-45.77, +69.41] 1 (metrics) (profiles) (logs)
otlp_ingest_logs_5mb_memory memory utilization +9.24 [+8.75, +9.73] 1 (metrics) (profiles) (logs)
otlp_ingest_traces_5mb_cpu % cpu utilization +8.24 [+5.71, +10.78] 1 (metrics) (profiles) (logs)
dsd_uds_100mb_3k_contexts_cpu % cpu utilization +1.29 [-4.67, +7.25] 1 (metrics) (profiles) (logs)
dsd_uds_10mb_3k_contexts_cpu % cpu utilization +0.96 [-29.25, +31.17] 1 (metrics) (profiles) (logs)
dsd_uds_10mb_3k_contexts_memory memory utilization +0.36 [+0.16, +0.56] 1 (metrics) (profiles) (logs)
dsd_uds_500mb_3k_contexts_memory memory utilization +0.36 [+0.17, +0.55] 1 (metrics) (profiles) (logs)
dsd_uds_512kb_3k_contexts_memory memory utilization +0.33 [+0.15, +0.51] 1 (metrics) (profiles) (logs)
quality_gates_rss_dsd_ultraheavy memory utilization +0.23 [+0.10, +0.37] 1 (metrics) (profiles) (logs)
dsd_uds_500mb_3k_contexts_cpu % cpu utilization +0.21 [-1.07, +1.48] 1 (metrics) (profiles) (logs)
dsd_uds_100mb_3k_contexts_memory memory utilization +0.19 [+0.00, +0.38] 1 (metrics) (profiles) (logs)
dsd_uds_1mb_3k_contexts_memory memory utilization +0.18 [-0.01, +0.36] 1 (metrics) (profiles) (logs)
quality_gates_rss_dsd_medium memory utilization +0.17 [-0.02, +0.37] 1 (metrics) (profiles) (logs)
otlp_ingest_traces_5mb_throughput ingress throughput +0.01 [-0.04, +0.06] 1 (metrics) (profiles) (logs)
otlp_ingest_logs_5mb_throughput ingress throughput +0.01 [-0.12, +0.14] 1 (metrics) (profiles) (logs)
dsd_uds_512kb_3k_contexts_throughput ingress throughput +0.01 [-0.05, +0.06] 1 (metrics) (profiles) (logs)
dsd_uds_1mb_3k_contexts_throughput ingress throughput +0.00 [-0.05, +0.06] 1 (metrics) (profiles) (logs)
otlp_ingest_metrics_5mb_throughput ingress throughput -0.00 [-0.13, +0.13] 1 (metrics) (profiles) (logs)
dsd_uds_10mb_3k_contexts_throughput ingress throughput -0.01 [-0.14, +0.13] 1 (metrics) (profiles) (logs)
dsd_uds_100mb_3k_contexts_throughput ingress throughput -0.01 [-0.06, +0.04] 1 (metrics) (profiles) (logs)
quality_gates_rss_dsd_low memory utilization -0.07 [-0.23, +0.09] 1 (metrics) (profiles) (logs)
quality_gates_rss_idle memory utilization -0.10 [-0.14, -0.05] 1 (metrics) (profiles) (logs)
quality_gates_rss_dsd_heavy memory utilization -0.19 [-0.31, -0.06] 1 (metrics) (profiles) (logs)
otlp_ingest_logs_5mb_cpu % cpu utilization -0.42 [-5.49, +4.65] 1 (metrics) (profiles) (logs)
dsd_uds_500mb_3k_contexts_throughput ingress throughput -0.49 [-0.62, -0.35] 1 (metrics) (profiles) (logs)
otlp_ingest_metrics_5mb_cpu % cpu utilization -0.70 [-6.72, +5.31] 1 (metrics) (profiles) (logs)
otlp_ingest_traces_5mb_memory memory utilization -1.31 [-2.01, -0.62] 1 (metrics) (profiles) (logs)
otlp_ingest_metrics_5mb_memory memory utilization -3.50 [-3.73, -3.28] 1 (metrics) (profiles) (logs)
dsd_uds_1mb_3k_contexts_cpu % cpu utilization -18.06 [-65.78, +29.65] 1 (metrics) (profiles) (logs)

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
quality_gates_rss_dsd_heavy memory_usage 10/10 (metrics) (profiles) (logs)
quality_gates_rss_dsd_low memory_usage 10/10 (metrics) (profiles) (logs)
quality_gates_rss_dsd_medium memory_usage 10/10 (metrics) (profiles) (logs)
quality_gates_rss_dsd_ultraheavy memory_usage 10/10 (metrics) (profiles) (logs)
quality_gates_rss_idle memory_usage 10/10 (metrics) (profiles) (logs)

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

Replicate Execution Details

We run multiple replicates for each experiment/variant. However, we allow replicates to be automatically retried if there are any failures, up to 8 times, at which point the replicate is marked dead and we are unable to run analysis for the entire experiment. We call each of these attempts at running replicates a replicate execution. This section lists all replicate executions that failed due to the target crashing or being oom killed.

Note: In the below tables we bucket failures by experiment, variant, and failure type. For each of these buckets we list out the replicate indexes that failed with an annotation signifying how many times said replicate failed with the given failure mode. In the below example the baseline variant of the experiment named experiment_with_failures had two replicates that failed by oom kills. Replicate 0, which failed 8 executions, and replicate 1 which failed 6 executions, all with the same failure mode.

Experiment Variant Replicates Failure Logs Debug Dashboard
experiment_with_failures baseline 0 (x8) 1 (x6) Oom killed Debug Dashboard

The debug dashboard links will take you to a debugging dashboard specifically designed to investigate replicate execution failures.

❌ Retried Normal Replicate Execution Failures (non-profiling)

Experiment Variant Replicates Failure Debug Dashboard
otlp_ingest_traces_5mb_throughput comparison 0 Failed to shutdown when requested Debug Dashboard
quality_gates_rss_dsd_low baseline 3 Failed to shutdown when requested Debug Dashboard
quality_gates_rss_dsd_ultraheavy baseline 3 Failed to shutdown when requested Debug Dashboard

}

#[async_trait]
impl Transform for TraceSampler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly saying this out loud so that I don't forget, but we'll likely want to end up making this a synchronous transform so that we can avoid the cost of message passing.

@andrewqian2001datadog andrewqian2001datadog changed the title (WIP) Andrewq/add trace sampling [AGNTLOG-468] chore(datadog): add trace sampling Jan 21, 2026
@andrewqian2001datadog andrewqian2001datadog marked this pull request as ready for review January 22, 2026 21:44
@andrewqian2001datadog andrewqian2001datadog requested a review from a team as a code owner January 22, 2026 21:44
@andrewqian2001datadog
Copy link
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link

gh-worker-devflow-routing-ef8351 bot commented Jan 28, 2026

View all feedbacks in Devflow UI.

2026-01-28 20:52:34 UTC ℹ️ Start processing command /merge


2026-01-28 20:52:50 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-01-28 21:28:07 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 25m (p90).


2026-01-28 21:43:32 UTC 🚨 MergeQueue: This merge request is in error

mergequeue build completed successfully, but the github api returned an error while merging the pr.
It's probably because:

  • some status checks are failing:
    • dd-gitlab/run-benchmarks-adp
  • target branch of PR is restricted to only allow up-to-date branches, but the pr is now outdated
Details

Error: PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (Request ID: ED00:4E0E8:DC70FE:3D2421E:697A82FB)

FullStacktrace:
activity error (type: github.GithubService_MergePullRequest, scheduledEventID: 52, startedEventID: 53, identity: 1@github-worker-5b5f778c9d-h7jnk@): PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (Request ID: ED00:4E0E8:DC70FE:3D2421E:697A82FB) (type: GitFailure, retryable: false): PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (type: ErrorResponse, retryable: true)

@andrewqian2001datadog
Copy link
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link

gh-worker-devflow-routing-ef8351 bot commented Jan 28, 2026

View all feedbacks in Devflow UI.

2026-01-28 21:45:01 UTC ℹ️ Start processing command /merge


2026-01-28 21:45:13 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 25m (p90).


2026-01-28 21:56:34 UTC 🚨 MergeQueue: This merge request is in error

mergequeue build completed successfully, but the github api returned an error while merging the pr.
It's probably because:

  • target branch of PR is restricted to only allow up-to-date branches, but the pr is now outdated
Details

Error: PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (Request ID: ED00:4E0E8:EBF2D4:416EA64:697A860B)

FullStacktrace:
activity error (type: github.GithubService_MergePullRequest, scheduledEventID: 52, startedEventID: 53, identity: 1@github-worker-5b5f778c9d-h7jnk@): PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (Request ID: ED00:4E0E8:EBF2D4:416EA64:697A860B) (type: GitFailure, retryable: false): PUT https://api.github.com/repos/DataDog/saluki/pulls/1110/merge: 405 Repository rule violations found

1 review requesting changes and 1 approving review by reviewers with write access.

14 of 14 required status checks are expected.

[] (type: ErrorResponse, retryable: true)

@andrewqian2001datadog
Copy link
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link

gh-worker-devflow-routing-ef8351 bot commented Jan 28, 2026

View all feedbacks in Devflow UI.

2026-01-28 21:57:10 UTC ℹ️ Start processing command /merge


2026-01-28 21:57:21 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-01-29 01:58:13 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

@tobz tobz merged commit e33b714 into main Jan 29, 2026
55 of 57 checks passed
@tobz tobz deleted the andrewq/add-trace-sampling branch January 29, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/components Sources, transforms, and destinations. area/core Core functionality, event model, etc. mergequeue-status: removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants